//
//  CZInPurchaseManager.m
//  LingVR
//
//  Created by MinLison on 16/8/9.
//  Copyright © 2016年 LingVR. All rights reserved.
//

#import "NYPurchaseUIManager.h"
#import "NYVIPListRequest.h"
#define NYVIP_LIST_CACHE_KEY  @"NYVIP_LIST_CACHE_KEY"
@implementation NYPurchaseUIManager

+ (BOOL)isvalideForID:(NSString *)ID
{
        return YES;
//        __block BOOL res = NO;
//        [[self getVipList] enumerateObjectsUsingBlock:^(NYVipPayModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                if ([obj.itunesID isEqualToString:ID])
//                {
//                        res = YES;
//                        *stop = YES;
//                }
//        }];
//        return res;
}
+ (NSArray<NYVipPayModel *> *)getVipList
{
        NSArray *array = (NSArray<NYVipPayModel *> *)[ShareStaticCache objectForKey:NYVIP_LIST_CACHE_KEY];
        if (array.count <= 0) {
                [self getAllCanPurchaseGoods:nil failed:nil];
        }
        return array;
}

+ (void)getAllCanPurchaseGoods:(RequestSuccessBlock)success failed:(RequestFailedBlock)failed
{
        [[NYVIPListRequest requestWithParams:nil] startWithSuccess:^(__kindof BaseRequest * _Nonnull request, __kindof NSArray<NYVipPayModel *> * _Nonnull data) {
                [ShareStaticCache setObject:data forKey:NYVIP_LIST_CACHE_KEY];
                if (success) {
                        success(request,data);
                }
        } failed:failed];
}
@end
